<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="一、创建仓库 在Github任意页面的右上角点击+号，然后选择New repository创建项目项目  使用Owner下拉菜单，然后选择要拥有该存储库的帐户，这里选择的是FENG1000。  输入存储库名称和可选描述。  存储库名称可以任意起，然后将静态资源部署在gh-pages，部署成功后访问地址为&lt;username&gt;.github.io&#x2F;[存储库名称]&#x2F; 想要实现直接通过&lt;">
<meta property="og:type" content="article">
<meta property="og:title" content="通过GitHub Pages+Hexo搭建个人博客">
<meta property="og:url" content="https:&#x2F;&#x2F;fengzxia.gitee.io&#x2F;posts&#x2F;ab50cd13.html">
<meta property="og:site_name" content="只是学习学习的博客">
<meta property="og:description" content="一、创建仓库 在Github任意页面的右上角点击+号，然后选择New repository创建项目项目  使用Owner下拉菜单，然后选择要拥有该存储库的帐户，这里选择的是FENG1000。  输入存储库名称和可选描述。  存储库名称可以任意起，然后将静态资源部署在gh-pages，部署成功后访问地址为&lt;username&gt;.github.io&#x2F;[存储库名称]&#x2F; 想要实现直接通过&lt;">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QOhgZF.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QO4EJs.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QOIgZ8.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QOo9L6.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QObEHP.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2020&#x2F;01&#x2F;07&#x2F;lcPQYD.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QOjQ0A.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QOj07n.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QXPXkQ.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QXiAk4.gif">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QXi3Ae.png">
<meta property="og:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QXFZVS.gif">
<meta property="article:published_time" content="2019-12-20T07:58:00.000Z">
<meta property="article:modified_time" content="2020-04-16T12:11:09.818Z">
<meta property="article:author" content="只是学习学习">
<meta property="article:tag" content="自建博客">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https:&#x2F;&#x2F;s2.ax1x.com&#x2F;2019&#x2F;12&#x2F;20&#x2F;QOhgZF.png">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
          
        
    
    <!-- title -->
    <title>通过GitHub Pages+Hexo搭建个人博客</title>
    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">

    <!-- persian styles -->
    
      
<link rel="stylesheet" href="/css/rtl.css">

    
    <!-- rss -->
    
    
    
<meta name="generator" content="Hexo 4.1.1"></head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">主页</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/friend_ship/">友链</a></li>
        
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" href="/posts/7bd3e3ff.html"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" href="/posts/9d815f7c.html"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">上一篇</span>
      <span id="i-next" class="info" style="display:none;">下一篇</span>
      <span id="i-top" class="info" style="display:none;">返回顶部</span>
      <span id="i-share" class="info" style="display:none;">分享文章</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=https://fengzxia.gitee.io/posts/ab50cd13.html" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=https://fengzxia.gitee.io/posts/ab50cd13.html&text=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=https://fengzxia.gitee.io/posts/ab50cd13.html&is_video=false&description=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=通过GitHub Pages+Hexo搭建个人博客&body=Check out this article: https://fengzxia.gitee.io/posts/ab50cd13.html"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=https://fengzxia.gitee.io/posts/ab50cd13.html&name=通过GitHub Pages+Hexo搭建个人博客&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=https://fengzxia.gitee.io/posts/ab50cd13.html&t=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#一、创建仓库"><span class="toc-number">1.</span> <span class="toc-text">一、创建仓库</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#二、安装Hexo"><span class="toc-number">2.</span> <span class="toc-text">二、安装Hexo</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#安装前提"><span class="toc-number">2.1.</span> <span class="toc-text">安装前提</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装Git"><span class="toc-number">2.2.</span> <span class="toc-text">安装Git</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Mac-用户"><span class="toc-number">2.2.1.</span> <span class="toc-text">Mac 用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Windows-用户"><span class="toc-number">2.2.2.</span> <span class="toc-text">Windows 用户</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装NodeJs"><span class="toc-number">2.3.</span> <span class="toc-text">安装NodeJs</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Windows-用户-1"><span class="toc-number">2.3.1.</span> <span class="toc-text">Windows 用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#For-Mac-Linux-用户"><span class="toc-number">2.3.2.</span> <span class="toc-text">For Mac &#x2F; Linux 用户</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装Hexo"><span class="toc-number">2.4.</span> <span class="toc-text">安装Hexo</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#进阶安装和使用"><span class="toc-number">2.5.</span> <span class="toc-text">进阶安装和使用</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#三、使用Hexo建站"><span class="toc-number">3.</span> <span class="toc-text">三、使用Hexo建站</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#config-yml"><span class="toc-number">3.1.</span> <span class="toc-text">_config.yml</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#package-json"><span class="toc-number">3.2.</span> <span class="toc-text">package.json</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#scaffolds"><span class="toc-number">3.3.</span> <span class="toc-text">scaffolds</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#source"><span class="toc-number">3.4.</span> <span class="toc-text">source</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#themes"><span class="toc-number">3.5.</span> <span class="toc-text">themes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#四、Hexo建站配置"><span class="toc-number">4.</span> <span class="toc-text">四、Hexo建站配置</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#网站"><span class="toc-number">4.1.</span> <span class="toc-text">网站</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#网址"><span class="toc-number">4.2.</span> <span class="toc-text">网址</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#网站存放在子目录"><span class="toc-number">4.2.1.</span> <span class="toc-text">网站存放在子目录</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#五、编写博客"><span class="toc-number">5.</span> <span class="toc-text">五、编写博客</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#布局（Layout）"><span class="toc-number">5.1.</span> <span class="toc-text">布局（Layout）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#不要处理我的文章"><span class="toc-number">5.1.1.</span> <span class="toc-text">不要处理我的文章</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#文件名称"><span class="toc-number">5.2.</span> <span class="toc-text">文件名称</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#草稿"><span class="toc-number">5.3.</span> <span class="toc-text">草稿</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#模版（Scaffold）"><span class="toc-number">5.4.</span> <span class="toc-text">模版（Scaffold）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#通过Admin插件在网页编写博客"><span class="toc-number">5.5.</span> <span class="toc-text">通过Admin插件在网页编写博客</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#六选择主题"><span class="toc-number">6.</span> <span class="toc-text">六选择主题</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#七、部署博客"><span class="toc-number">7.</span> <span class="toc-text">七、部署博客</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#本地部署预览"><span class="toc-number">7.1.</span> <span class="toc-text">本地部署预览</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#clean"><span class="toc-number">7.2.</span> <span class="toc-text">clean</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#generate"><span class="toc-number">7.3.</span> <span class="toc-text">generate</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#部署前配置"><span class="toc-number">7.3.1.</span> <span class="toc-text">部署前配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#部署上传"><span class="toc-number">7.3.2.</span> <span class="toc-text">部署上传</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#码云Pages部署后需要自己手动点击下构建才可以"><span class="toc-number">7.3.3.</span> <span class="toc-text">码云Pages部署后需要自己手动点击下构建才可以</span></a></li></ol></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        通过GitHub Pages+Hexo搭建个人博客
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">只是学习学习的博客</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2019-12-20T07:58:00.000Z" itemprop="datePublished">2019-12-20</time>
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/Hexo/">Hexo</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/%E8%87%AA%E5%BB%BA%E5%8D%9A%E5%AE%A2/" rel="tag">自建博客</a>
    </div>


    </div>
  </header>
  

  <div class="content"itemprop ="articleBody">
    <h1 id="一、创建仓库"><a href="#一、创建仓库" class="headerlink" title="一、创建仓库"></a>一、创建仓库</h1><ol>
<li><p>在Github任意页面的右上角点击<code>+</code>号，然后选择<code>New repository</code>创建项目<br><img src="https://s2.ax1x.com/2019/12/20/QOhgZF.png" alt="QOhgZF.png"><br>项目</p>
</li>
<li><p>使用<code>Owner</code>下拉菜单，然后选择要拥有该存储库的帐户，这里选择的是FENG1000。<br><img src="https://s2.ax1x.com/2019/12/20/QO4EJs.png" alt="QO4EJs.png"></p>
</li>
<li><p>输入存储库名称和可选描述。</p>
<ol>
<li>存储库名称可以任意起，然后将静态资源部署在<code>gh-pages</code>，部署成功后访问地址为<code>&lt;username&gt;.github.io/[存储库名称]/</code></li>
<li>想要实现直接通过<code>&lt;username&gt;.github.io</code>方式访问博客则存储库命名必须为<code>&lt;username&gt;.github.io</code>，例如：用户名为<code>FENG1000</code>，则要创建的存储库名为<code>FENG1000.github.io</code>。我这里因为已经创建过所以提示已存在。<br><img src="https://s2.ax1x.com/2019/12/20/QOIgZ8.png" alt="QOIgZ8.png"></li>
</ol>
</li>
<li><p>选择将存储库设为公共或私有。公开存储库对公众可见，而私有存储库仅供你以及与之共享的人访问。<br><img src="https://s2.ax1x.com/2019/12/20/QOo9L6.png" alt="QOo9L6.png"></p>
</li>
<li><p>单击<code>Ceate repository</code>创建存储库。</p>
</li>
</ol>
<blockquote>
<p>如果想通过码云创建 <strong>码云Pages</strong> 可参考 <a href="https://gitee.com/help/categories/56" target="_blank" rel="noopener">官方</a></p>
</blockquote>
<h1 id="二、安装Hexo"><a href="#二、安装Hexo" class="headerlink" title="二、安装Hexo"></a>二、安装Hexo</h1><h2 id="安装前提"><a href="#安装前提" class="headerlink" title="安装前提"></a>安装前提</h2><p>安装 Hexo 相当简单，只需要先安装下列应用程序即可：</p>
<ul>
<li>Node.js (Node.js 版本需不低于 8.10，建议使用 Node.js 10.0 及以上版本)</li>
<li>Git<br>如果你的电脑中已经安装上述必备程序， 可以直接前往 <a href="#安装Hexo">安装Hexo</a> 步骤。</li>
</ul>
<p>如果电脑中尚未安装所需要的程序，请根据以下安装指示完成安装。</p>
<h2 id="安装Git"><a href="#安装Git" class="headerlink" title="安装Git"></a>安装Git</h2><ul>
<li>Windows：下载并安装 <a href="https://git-scm.com/download/win" target="_blank" rel="noopener">git</a>.</li>
<li>Mac：使用 <a href="http://mxcl.github.com/homebrew/" target="_blank" rel="noopener">Homebrew</a>, <a href="http://www.macports.org/" target="_blank" rel="noopener">MacPorts</a> 或者下载 <a href="http://sourceforge.net/projects/git-osx-installer/" target="_blank" rel="noopener">安装程序</a>。</li>
<li>Linux (Ubuntu, Debian)：<code>sudo apt-get install git-core</code></li>
<li>Linux (Fedora, Red Hat, CentOS)：<code>sudo yum install git-core</code></li>
</ul>
<blockquote>
<h3 id="Mac-用户"><a href="#Mac-用户" class="headerlink" title="Mac 用户"></a>Mac 用户</h3><p>如果在编译时可能会遇到问题，请先到 App Store 安装 Xcode，Xcode 完成后，启动并进入 <strong>Preferences -&gt; Download -&gt; Command Line Tools -&gt; Install</strong> 安装命令行工具。</p>
</blockquote>
<blockquote>
<h3 id="Windows-用户"><a href="#Windows-用户" class="headerlink" title="Windows 用户"></a>Windows 用户</h3><p>对于中国大陆地区用户，可以前往 <a href="https://npm.taobao.org/mirrors/git-for-windows/" target="_blank" rel="noopener">淘宝 Git for Windows 镜像</a> 下载 git 安装包。</p>
</blockquote>
<h2 id="安装NodeJs"><a href="#安装NodeJs" class="headerlink" title="安装NodeJs"></a>安装NodeJs</h2><p>Node.js 为大多数平台提供了官方的 <a href="https://nodejs.org/en/download/" target="_blank" rel="noopener">安装程序</a>。对于中国大陆地区用户，可以前往 <a href="https://npm.taobao.org/mirrors/node" target="_blank" rel="noopener">淘宝 Node.js 镜像</a> 下载。其它的安装方法：</p>
<ul>
<li>Windows：通过 <a href="https://github.com/jasongin/nvs/" target="_blank" rel="noopener">nvs</a>（推荐）或者<a href="https://github.com/nvm-sh/nvm" target="_blank" rel="noopener">nvm</a> 安装。</li>
<li>Mac：使用 <a href="https://brew.sh/" target="_blank" rel="noopener">Homebrew</a> 或 <a href="http://www.macports.org/" target="_blank" rel="noopener">MacPorts</a> 安装。</li>
<li>Linux（DEB/RPM-based）：从 <a href="https://github.com/nodesource/distributions" target="_blank" rel="noopener">NodeSource</a> 安装。</li>
<li>其它：使用相应的软件包管理器进行安装，可以参考由 Node.js 提供的 <a href="https://nodejs.org/en/download/package-manager/" target="_blank" rel="noopener">指导</a></li>
</ul>
<p>对于 Mac 和 Linux 同样建议使用 nvs 或者 nvm，以避免可能会出现的权限问题。</p>
<blockquote>
<h3 id="Windows-用户-1"><a href="#Windows-用户-1" class="headerlink" title="Windows 用户"></a>Windows 用户</h3><p>使用 Node.js 官方安装程序时，请确保勾选 <strong>Add to PATH</strong> 选项（默认已勾选）</p>
</blockquote>
<blockquote>
<h3 id="For-Mac-Linux-用户"><a href="#For-Mac-Linux-用户" class="headerlink" title="For Mac / Linux 用户"></a>For Mac / Linux 用户</h3><p>如果在尝试安装 Hexo 的过程中出现 <code>EACCES</code> 权限错误，请遵循 <a href="https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally" target="_blank" rel="noopener">由 npmjs 发布的指导</a> 修复该问题。强烈建议 不要 使用 root、sudo 等方法覆盖权限</p>
</blockquote>
<h2 id="安装Hexo"><a href="#安装Hexo" class="headerlink" title="安装Hexo"></a>安装Hexo</h2><p>所有必备的应用程序安装完成后，即可使用 npm 安装 Hexo。</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo-cli</span><br></pre></td></tr></table></figure>

<h2 id="进阶安装和使用"><a href="#进阶安装和使用" class="headerlink" title="进阶安装和使用"></a>进阶安装和使用</h2><p>对于熟悉 npm 的进阶用户，可以仅局部安装 <code>hexo</code> 包。</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo</span><br></pre></td></tr></table></figure>

<p>安装以后，可以使用以下两种方式执行 Hexo：</p>
<ol>
<li><code>npx hexo &lt;command&gt;</code></li>
<li>将 Hexo 所在的目录下的 <code>node_modules</code> 添加到环境变量之中即可直接使用 <code>hexo &lt;command&gt;</code>：<br><img src="https://s2.ax1x.com/2019/12/20/QObEHP.png" alt="QObEHP.png"></li>
</ol>
<h1 id="三、使用Hexo建站"><a href="#三、使用Hexo建站" class="headerlink" title="三、使用Hexo建站"></a>三、使用Hexo建站</h1><p>安装 Hexo 完成后，执行下列命令，Hexo 将会在指定文件夹中新建所需要的文件。</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo init &lt;folder&gt;</span><br><span class="line">cd &lt;folder&gt;</span><br><span class="line">npm install</span><br></pre></td></tr></table></figure>

<p>新建完成后，指定文件夹的目录如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">├── _config.yml</span><br><span class="line">├── package.json</span><br><span class="line">├── scaffolds</span><br><span class="line">├── source</span><br><span class="line">|   ├── _drafts</span><br><span class="line">|   └── _posts</span><br><span class="line">└── themes</span><br></pre></td></tr></table></figure>

<h2 id="config-yml"><a href="#config-yml" class="headerlink" title="_config.yml"></a>_config.yml</h2><p>网站的 <a href="https://hexo.io/zh-cn/docs/configuration" target="_blank" rel="noopener">配置</a> 信息，您可以在此配置大部分的参数。</p>
<h2 id="package-json"><a href="#package-json" class="headerlink" title="package.json"></a>package.json</h2><p>应用程序的信息。<a href="https://ejs.co/" target="_blank" rel="noopener">EJS</a>, <a href="http://learnboost.github.io/stylus/" target="_blank" rel="noopener">Stylus</a> 和 <a href="http://daringfireball.net/projects/markdown/" target="_blank" rel="noopener">Markdown</a> renderer 已默认安装，可以自由移除。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&#123;</span><br><span class="line">  <span class="attr">"name"</span>: <span class="string">"hexo-site"</span>,</span><br><span class="line">  <span class="attr">"version"</span>: <span class="string">"0.0.0"</span>,</span><br><span class="line">  <span class="attr">"private"</span>: <span class="literal">true</span>,</span><br><span class="line">  <span class="attr">"hexo"</span>: &#123;</span><br><span class="line">    <span class="attr">"version"</span>: <span class="string">""</span></span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="attr">"dependencies"</span>: &#123;</span><br><span class="line">    <span class="attr">"hexo"</span>: <span class="string">"^3.8.0"</span>,</span><br><span class="line">    <span class="attr">"hexo-generator-archive"</span>: <span class="string">"^0.1.5"</span>,</span><br><span class="line">    <span class="attr">"hexo-generator-category"</span>: <span class="string">"^0.1.3"</span>,</span><br><span class="line">    <span class="attr">"hexo-generator-index"</span>: <span class="string">"^0.2.1"</span>,</span><br><span class="line">    <span class="attr">"hexo-generator-tag"</span>: <span class="string">"^0.2.0"</span>,</span><br><span class="line">    <span class="attr">"hexo-renderer-ejs"</span>: <span class="string">"^0.3.1"</span>,</span><br><span class="line">    <span class="attr">"hexo-renderer-stylus"</span>: <span class="string">"^0.3.3"</span>,</span><br><span class="line">    <span class="attr">"hexo-renderer-marked"</span>: <span class="string">"^0.3.2"</span>,</span><br><span class="line">    <span class="attr">"hexo-server"</span>: <span class="string">"^0.3.3"</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="scaffolds"><a href="#scaffolds" class="headerlink" title="scaffolds"></a>scaffolds</h2><p><a href="https://hexo.io/zh-cn/docs/writing" target="_blank" rel="noopener">模版</a> 文件夹。当您新建文章时，Hexo 会根据 scaffold 来建立文件。</p>
<p>Hexo的模板是指在新建的文章文件中默认填充的内容。例如，如果修改<code>scaffold/post.md</code>中的<code>Front-matter</code>内容，那么每次新建一篇文章时都会包含这个修改。</p>
<h2 id="source"><a href="#source" class="headerlink" title="source"></a>source</h2><p>资源文件夹是存放用户资源的地方。除 <code>_posts</code> 文件夹之外，开头命名为 <code>_</code> (下划线)的文件 <code>/</code> 文件夹和隐藏的文件将会被忽略。Markdown 和 HTML 文件会被解析并放到 <code>public</code> 文件夹，而其他文件会被拷贝过去。</p>
<h2 id="themes"><a href="#themes" class="headerlink" title="themes"></a>themes</h2><p><a href="https://hexo.io/zh-cn/docs/themes" target="_blank" rel="noopener">主题</a> 文件夹。Hexo 会根据主题来生成静态页面。</p>
<h1 id="四、Hexo建站配置"><a href="#四、Hexo建站配置" class="headerlink" title="四、Hexo建站配置"></a>四、Hexo建站配置</h1><p>可以在 <code>_config.yml</code> 中修改大部分的配置。</p>
<h2 id="网站"><a href="#网站" class="headerlink" title="网站"></a>网站</h2><table>
<thead>
<tr>
<th>参数</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>title</td>
<td>网站标题</td>
</tr>
<tr>
<td>subtitle</td>
<td>网站副标题</td>
</tr>
<tr>
<td>description</td>
<td>网站描述</td>
</tr>
<tr>
<td>keywords</td>
<td>网站的关键词。使用半角逗号 , 分隔多个关键词。</td>
</tr>
<tr>
<td>author</td>
<td>你的名字</td>
</tr>
<tr>
<td>language</td>
<td>网站使用的语言，如: <code>en</code>, <code>zh-CN</code></td>
</tr>
<tr>
<td>timezone</td>
<td>网站时区。Hexo 默认使用您电脑的时区。请参考 时区列表 进行设置，如 <code>America/New_York</code>, <code>Japan</code>, 和 <code>UTC</code> 。一般的，对于中国大陆地区可以使用 <code>Asia/Shanghai</code>。</td>
</tr>
</tbody></table>
<p>其中，<code>description</code>主要用于SEO，告诉搜索引擎一个关于您站点的简单描述，通常建议在其中包含您网站的关键词。<code>author</code>参数用于主题显示文章的作者。</p>
<h2 id="网址"><a href="#网址" class="headerlink" title="网址"></a>网址</h2><table>
<thead>
<tr>
<th>参数</th>
<th>描述</th>
<th>默认值</th>
</tr>
</thead>
<tbody><tr>
<td>url</td>
<td>网址</td>
<td></td>
</tr>
<tr>
<td>root</td>
<td>网站根目录</td>
<td></td>
</tr>
<tr>
<td>permalink</td>
<td>文章的 永久链接 格式</td>
<td></td>
</tr>
<tr>
<td>permalink_defaults</td>
<td>永久链接中各部分的默认值</td>
<td></td>
</tr>
<tr>
<td>pretty_urls</td>
<td>改写 permalink 的值来美化 URL</td>
<td></td>
</tr>
<tr>
<td>pretty_urls.trailing_index</td>
<td>是否在永久链接中保留尾部的 index.html，设置为 false 时去除</td>
<td>true</td>
</tr>
<tr>
<td>pretty_urls.trailing_html</td>
<td>是否在永久链接中保留尾部的 .html, 设置为 false 时去除 (对尾部的 index.html无效)</td>
<td>true</td>
</tr>
</tbody></table>
<blockquote>
<h3 id="网站存放在子目录"><a href="#网站存放在子目录" class="headerlink" title="网站存放在子目录"></a>网站存放在子目录</h3><p>如果您的网站存放在子目录中，例如 <code>http://yoursite.com/blog</code>，则请将您的 <code>url</code> 设为 <code>http://yoursite.com/blog</code> 并把 <code>root</code> 设为 <code>/blog/</code>。</p>
</blockquote>
<p>例如：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 比如，一个页面的永久链接是 http://example.com/foo/bar/index.html</span></span><br><span class="line"><span class="attr">pretty_urls:</span></span><br><span class="line">  <span class="attr">trailing_index:</span> <span class="literal">false</span></span><br><span class="line"><span class="comment"># 此时页面的永久链接会变为 http://example.com/foo/bar/</span></span><br></pre></td></tr></table></figure>

<p>这里只对部分常用配置讲解，详细参考<a href="https://hexo.io/zh-cn/docs/configuration" target="_blank" rel="noopener">官网</a></p>
<h1 id="五、编写博客"><a href="#五、编写博客" class="headerlink" title="五、编写博客"></a>五、编写博客</h1><p>你可以执行下列命令来创建一篇新文章或者新的页面。</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new [layout] &lt;title&gt;</span><br></pre></td></tr></table></figure>
<p>您可以在命令中指定文章的布局（layout），默认为 <code>post</code>，可以通过修改 <code>_config.yml</code> 中的 <code>default_layout</code> 参数来指定默认布局。</p>
<h2 id="布局（Layout）"><a href="#布局（Layout）" class="headerlink" title="布局（Layout）"></a>布局（Layout）</h2><p>Hexo 有三种默认布局：<code>post</code>、<code>page</code> 和 <code>draft</code>。在创建者三种不同类型的文件时，它们将会被保存到不同的路径；而您自定义的其他布局和 <code>post</code> 相同，都将储存到 <code>source/_posts</code> 文件夹。</p>
<table>
<thead>
<tr>
<th>布局</th>
<th>路径</th>
</tr>
</thead>
<tbody><tr>
<td><code>post</code></td>
<td><code>source/_posts</code></td>
</tr>
<tr>
<td><code>page</code></td>
<td><code>source</code></td>
</tr>
<tr>
<td><code>draft</code></td>
<td><code>source/_drafts</code></td>
</tr>
</tbody></table>
<blockquote>
<h3 id="不要处理我的文章"><a href="#不要处理我的文章" class="headerlink" title="不要处理我的文章"></a>不要处理我的文章</h3><p>如果你不想你的文章被处理，你可以将 Front-Matter 中的layout: 设为 false 。</p>
</blockquote>
<h2 id="文件名称"><a href="#文件名称" class="headerlink" title="文件名称"></a>文件名称</h2><p>Hexo 默认以标题做为文件名称，但您可编辑 <code>new_post_name</code> 参数来改变默认的文件名称，举例来说，设为 <code>:year-:month-:day-:title.md</code> 可让您更方便的通过日期来管理文章。配置后输入<code>hexo new 博客标题</code>，就会自动创建为<code>当前日期-标题</code>名字的<code>.md</code>文件</p>
<table>
<thead>
<tr>
<th>变量</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>:title</code></td>
<td>标题（小写，空格将会被替换为短杠）</td>
</tr>
<tr>
<td><code>:year</code></td>
<td>建立的年份，比如， <code>2015</code></td>
</tr>
<tr>
<td><code>:month</code></td>
<td>建立的月份（有前导零），比如， <code>04</code></td>
</tr>
<tr>
<td><code>:i_month</code></td>
<td>建立的月份（无前导零），比如， <code>4</code></td>
</tr>
<tr>
<td><code>:day</code></td>
<td>建立的日期（有前导零），比如， <code>07</code></td>
</tr>
<tr>
<td><code>:i_day</code></td>
<td>建立的日期（无前导零），比如， <code>7</code></td>
</tr>
</tbody></table>
<h2 id="草稿"><a href="#草稿" class="headerlink" title="草稿"></a>草稿</h2><p>刚刚提到了 Hexo 的一种特殊布局：<code>draft</code>，这种布局在建立时会被保存到 <code>source/_drafts</code> 文件夹，您可通过 <code>publish</code> 命令将草稿移动到 <code>source/_posts</code> 文件夹，该命令的使用方式与 <code>new</code> 十分类似，您也可在命令中指定 <code>layout</code> 来指定布局。</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo publish [layout] &lt;title&gt;</span><br></pre></td></tr></table></figure>

<p>草稿默认不会显示在页面中，您可在执行时加上 <code>--draft</code> 参数，或是把 <code>render_drafts</code> 参数设为 <code>true</code> 来预览草稿。</p>
<h2 id="模版（Scaffold）"><a href="#模版（Scaffold）" class="headerlink" title="模版（Scaffold）"></a>模版（Scaffold）</h2><p>在新建文章时，Hexo 会根据 <code>scaffolds</code> 文件夹内相对应的文件来建立文件，例如：</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new photo "My Gallery"</span><br></pre></td></tr></table></figure>
<p>在执行这行指令时，Hexo 会尝试在 <code>scaffolds</code> 文件夹中寻找 <code>photo.md</code>，并根据其内容建立文章，以下是您可以在模版中使用的变量：</p>
<table>
<thead>
<tr>
<th>变量</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>layout</code></td>
<td>布局</td>
</tr>
<tr>
<td><code>title</code></td>
<td>标题</td>
</tr>
<tr>
<td><code>date</code></td>
<td>文件建立日期</td>
</tr>
</tbody></table>
<h2 id="通过Admin插件在网页编写博客"><a href="#通过Admin插件在网页编写博客" class="headerlink" title="通过Admin插件在网页编写博客"></a>通过Admin插件在网页编写博客</h2><p>可以通过命令 <code>npm install --save hexo-admin</code> 来安装一个Hexo的后台管理，然后通过输入<code>hexo s -d</code>启动本地服务访问<code>http://localhost:4000/admin</code>即可进入后台。<br><img src="https://s2.ax1x.com/2020/01/07/lcPQYD.png" alt="lcPQYD.png"></p>
<ul>
<li><code>Pages</code>: 新加 页面</li>
<li><code>Posts</code>: 新加或删除 post；双击一个 post，你可以编辑，预览，新增修改 tags、categories，选择发布或不发布；</li>
<li><code>Settings</code>: 一些配置，设置账户密码</li>
<li><code>Deploy</code>: 可以直接部署到 github<br>详细可参考<a href="https://github.com/jaredly/hexo-admin" target="_blank" rel="noopener">官方文档</a></li>
</ul>
<h1 id="六选择主题"><a href="#六选择主题" class="headerlink" title="六选择主题"></a>六选择主题</h1><p>Hexo的<a href="https://hexo.io/themes/" target="_blank" rel="noopener">主题搜索网站</a><br>在页面选择自己想要的主题<br><img src="https://s2.ax1x.com/2019/12/20/QOjQ0A.png" alt="QOjQ0A.png"></p>
<p>以 <a href="https://github.com/probberechts/hexo-theme-cactus" target="_blank" rel="noopener">Cactus</a> 主题为例</p>
<ol>
<li><p>点击进入主题的GitHub地址<br><img src="https://s2.ax1x.com/2019/12/20/QOj07n.png" alt="QOj07n.png"></p>
</li>
<li><p>从GitHub上下载到自己的<code>themes</code>目录下</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus</span><br></pre></td></tr></table></figure>

</li>
</ol>
<p>更改项目跟目录下<code>_config.yml</code>的 <code>theme</code> 属性为 下载的主题名称 以下载到 <code>themes</code> 目录中的文件名为主。</p>
<p>其他主题内的详细配置具体需要参考主题文件目录内的<code>README.md</code>或<code>_config.yml</code>中的注释进行配置</p>
<h1 id="七、部署博客"><a href="#七、部署博客" class="headerlink" title="七、部署博客"></a>七、部署博客</h1><h2 id="本地部署预览"><a href="#本地部署预览" class="headerlink" title="本地部署预览"></a>本地部署预览</h2><p>启动服务器。</p>
<figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo server</span><br></pre></td></tr></table></figure>
<p>默认情况下，访问网址为： <code>http://localhost:4000/</code>。</p>
<table>
<thead>
<tr>
<th>选项</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>-p</code>, <code>--port</code></td>
<td>重设端口</td>
</tr>
<tr>
<td><code>-s</code>, <code>--static</code></td>
<td>只使用静态文件</td>
</tr>
<tr>
<td><code>-l</code>, <code>--log</code></td>
<td>启动日记记录，使用覆盖记录格式</td>
</tr>
</tbody></table>
<h2 id="clean"><a href="#clean" class="headerlink" title="clean"></a>clean</h2><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br></pre></td></tr></table></figure>
<p>清除缓存文件 (<code>db.json</code>) 和已生成的静态文件 (<code>public</code>)。<br>在某些情况（尤其是更换主题后），如果发现您对站点的更改无论如何也不生效，您可能需要运行该命令。</p>
<h2 id="generate"><a href="#generate" class="headerlink" title="generate"></a>generate</h2><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo generate</span><br></pre></td></tr></table></figure>
<p>生成静态文件。</p>
<table>
<thead>
<tr>
<th>选项</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>-d</code>, <code>--deploy</code></td>
<td>文件生成后立即部署网站</td>
</tr>
<tr>
<td><code>-w</code>, <code>--watch</code></td>
<td>监视文件变动</td>
</tr>
<tr>
<td><code>-b</code>, <code>--bail</code></td>
<td>生成过程中如果发生任何未处理的异常则抛出异常</td>
</tr>
<tr>
<td><code>-f</code>, <code>--force</code></td>
<td>强制重新生成文件 Hexo 引入了差分机制，如果 <code>public</code> 目录存在，那么 <code>hexo g</code> 只会重新生成改动的文件。 使用该参数的效果接近 <code>hexo clean &amp;&amp; hexo generate</code></td>
</tr>
<tr>
<td><code>-c</code>, <code>--concurrency</code></td>
<td>最大同时生成文件的数量，默认无限制</td>
</tr>
<tr>
<td>该命令可以简写为</td>
<td></td>
</tr>
<tr>
<td><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br></pre></td></tr></table></figure></td>
<td></td>
</tr>
<tr>
<td>## deploy</td>
<td></td>
</tr>
<tr>
<td><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo deploy</span><br></pre></td></tr></table></figure></td>
<td></td>
</tr>
<tr>
<td>部署网站。</td>
<td></td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th>参数</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>-g</code>, <code>--generate</code></td>
<td>部署之前预先生成静态文件</td>
</tr>
<tr>
<td>该命令可以简写为：</td>
<td></td>
</tr>
<tr>
<td><figure class="highlight shell"><figcaption><span>script</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo d</span><br></pre></td></tr></table></figure></td>
<td></td>
</tr>
</tbody></table>
<h3 id="部署前配置"><a href="#部署前配置" class="headerlink" title="部署前配置"></a>部署前配置</h3><p>先输入<code>npm install hexo-deployer-git --save</code> 安装hexo推送到Git插件<br>跟目录的<code>_config.yml</code>中配置此插件。例如</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">deploy:</span></span><br><span class="line">  <span class="comment"># 指定通过上传git方式部署</span></span><br><span class="line">  <span class="attr">type:</span> <span class="string">git</span></span><br><span class="line">  <span class="comment"># git项目地址</span></span><br><span class="line">  <span class="attr">repo:</span> <span class="string">https://github.com/FENG1000/FENG1000.github.io</span></span><br><span class="line">  <span class="comment"># 指定上传的分支，如果不是以 &lt;username&gt;.github.io则需要上传到`gh-pages`分支</span></span><br><span class="line">  <span class="attr">branch:</span> <span class="string">master</span></span><br></pre></td></tr></table></figure>

<h3 id="部署上传"><a href="#部署上传" class="headerlink" title="部署上传"></a>部署上传</h3><ol>
<li>部署前最好先清除缓存，再重新构建<code>hexo g -f</code></li>
<li>执行 <code>hexo d</code> 命令，输入github验证信息进行部署<br><img src="https://s2.ax1x.com/2019/12/20/QXPXkQ.png" alt="QXPXkQ.png"></li>
<li>在GitHub的博客仓库内点击 <code>Settings</code> 查看部署情况，变为绿色说明部署成功<br><img src="https://s2.ax1x.com/2019/12/20/QXiAk4.gif" alt="QXiAk4.gif"></li>
<li>查看效果<br><img src="https://s2.ax1x.com/2019/12/20/QXi3Ae.png" alt="QXi3Ae.png"></li>
</ol>
<blockquote>
<h3 id="码云Pages部署后需要自己手动点击下构建才可以"><a href="#码云Pages部署后需要自己手动点击下构建才可以" class="headerlink" title="码云Pages部署后需要自己手动点击下构建才可以"></a>码云Pages部署后需要自己手动点击下构建才可以</h3><p><img src="https://s2.ax1x.com/2019/12/20/QXFZVS.gif" alt="QXFZVS.gif"></p>
</blockquote>

<div id="gitalk-container"></div>
<script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script><link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"><script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>

		<script>
		var gitalkConfig = {"clientID":"28a065e3b5afee156f4f","clientSecret":"e18104d6f3219526491fc42c892ff6a26b8f3e74","repo":"blog_comment","owner":"FENG1000","admin":["FENG1000"],"distractionFreeMode":false};
	    gitalkConfig.id = md5(location.pathname);
		var gitalk = new Gitalk(gitalkConfig);
	    gitalk.render("gitalk-container");
	    </script>
    
  <blockquote>
      <p>
          作者: 只是学习学习<br>
          邮箱: fengzxia1000@163.com<br>
          原文地址: <a href="https://fengzxia.gitee.io/posts/ab50cd13.html" target="_blank" rel="noopener">https://fengzxia.gitee.io/posts/ab50cd13.html</a><br>
          版权声明: 商业转载请联系作者获得授权，非商业转载请注明出处。
      </p>
  </blockquote>

  <script>
      function setClipboardText(event){
          // clipboardData 对象是为通过编辑菜单、快捷菜单和快捷键执行的编辑操作所保留的，也就是你复制或者剪切内容
          let clipboardData = event.clipboardData || window.clipboardData;
          // 如果未复制或者未剪切，则return出去
          if (!clipboardData) { return; }
          event.preventDefault();
          // Selection 对象，表示用户选择的文本范围或光标的当前位置。
          //     声明一个变量接收 -- 用户输入的剪切或者复制的文本转化为字符串
          let text = window.getSelection().toString();

          if (text) {
            // 如果文本存在则先取消文本默认事件
            event.preventDefault();
            // 通过调用常clipboardData对象的 setData(format, data) 方法；来设置相关文本
            // format: 一个DOMString 表示要添加到 drag object的拖动数据的类型。
            // data: 一个 DOMString表示要添加到 drag object的数据。
            var copyright = '\n\n'
                            + '\n著作权归作者所有。'
                            + '\n商业转载请联系作者获得授权，非商业转载请注明出处。'
                            + '\n作者: 只是学习学习'
                            + '\n邮箱: fengzxia1000@163.com'
                            + '\n原文地址: https://fengzxia.gitee.io/posts/ab50cd13.html'

            clipboardData.setData('text/plain', text + copyright);

          }
      };
      var contents = document.getElementsByClassName("content");
      // 监听文章内容的copy事件
      contents[0].addEventListener('copy',function(e){
          setClipboardText(e);
      });
  </script>

  </div>
</article>




        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">主页</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/friend_ship/">友链</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#一、创建仓库"><span class="toc-number">1.</span> <span class="toc-text">一、创建仓库</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#二、安装Hexo"><span class="toc-number">2.</span> <span class="toc-text">二、安装Hexo</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#安装前提"><span class="toc-number">2.1.</span> <span class="toc-text">安装前提</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装Git"><span class="toc-number">2.2.</span> <span class="toc-text">安装Git</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Mac-用户"><span class="toc-number">2.2.1.</span> <span class="toc-text">Mac 用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Windows-用户"><span class="toc-number">2.2.2.</span> <span class="toc-text">Windows 用户</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装NodeJs"><span class="toc-number">2.3.</span> <span class="toc-text">安装NodeJs</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Windows-用户-1"><span class="toc-number">2.3.1.</span> <span class="toc-text">Windows 用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#For-Mac-Linux-用户"><span class="toc-number">2.3.2.</span> <span class="toc-text">For Mac &#x2F; Linux 用户</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#安装Hexo"><span class="toc-number">2.4.</span> <span class="toc-text">安装Hexo</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#进阶安装和使用"><span class="toc-number">2.5.</span> <span class="toc-text">进阶安装和使用</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#三、使用Hexo建站"><span class="toc-number">3.</span> <span class="toc-text">三、使用Hexo建站</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#config-yml"><span class="toc-number">3.1.</span> <span class="toc-text">_config.yml</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#package-json"><span class="toc-number">3.2.</span> <span class="toc-text">package.json</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#scaffolds"><span class="toc-number">3.3.</span> <span class="toc-text">scaffolds</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#source"><span class="toc-number">3.4.</span> <span class="toc-text">source</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#themes"><span class="toc-number">3.5.</span> <span class="toc-text">themes</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#四、Hexo建站配置"><span class="toc-number">4.</span> <span class="toc-text">四、Hexo建站配置</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#网站"><span class="toc-number">4.1.</span> <span class="toc-text">网站</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#网址"><span class="toc-number">4.2.</span> <span class="toc-text">网址</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#网站存放在子目录"><span class="toc-number">4.2.1.</span> <span class="toc-text">网站存放在子目录</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#五、编写博客"><span class="toc-number">5.</span> <span class="toc-text">五、编写博客</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#布局（Layout）"><span class="toc-number">5.1.</span> <span class="toc-text">布局（Layout）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#不要处理我的文章"><span class="toc-number">5.1.1.</span> <span class="toc-text">不要处理我的文章</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#文件名称"><span class="toc-number">5.2.</span> <span class="toc-text">文件名称</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#草稿"><span class="toc-number">5.3.</span> <span class="toc-text">草稿</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#模版（Scaffold）"><span class="toc-number">5.4.</span> <span class="toc-text">模版（Scaffold）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#通过Admin插件在网页编写博客"><span class="toc-number">5.5.</span> <span class="toc-text">通过Admin插件在网页编写博客</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#六选择主题"><span class="toc-number">6.</span> <span class="toc-text">六选择主题</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#七、部署博客"><span class="toc-number">7.</span> <span class="toc-text">七、部署博客</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#本地部署预览"><span class="toc-number">7.1.</span> <span class="toc-text">本地部署预览</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#clean"><span class="toc-number">7.2.</span> <span class="toc-text">clean</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#generate"><span class="toc-number">7.3.</span> <span class="toc-text">generate</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#部署前配置"><span class="toc-number">7.3.1.</span> <span class="toc-text">部署前配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#部署上传"><span class="toc-number">7.3.2.</span> <span class="toc-text">部署上传</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#码云Pages部署后需要自己手动点击下构建才可以"><span class="toc-number">7.3.3.</span> <span class="toc-text">码云Pages部署后需要自己手动点击下构建才可以</span></a></li></ol></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=https://fengzxia.gitee.io/posts/ab50cd13.html" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=https://fengzxia.gitee.io/posts/ab50cd13.html&text=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=https://fengzxia.gitee.io/posts/ab50cd13.html&is_video=false&description=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=通过GitHub Pages+Hexo搭建个人博客&body=Check out this article: https://fengzxia.gitee.io/posts/ab50cd13.html"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=https://fengzxia.gitee.io/posts/ab50cd13.html&title=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=https://fengzxia.gitee.io/posts/ab50cd13.html&name=通过GitHub Pages+Hexo搭建个人博客&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=https://fengzxia.gitee.io/posts/ab50cd13.html&t=通过GitHub Pages+Hexo搭建个人博客" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> 菜单</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> 目录</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> 分享</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> 返回顶部</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy;
    
    
    2019-2020
    只是学习学习
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">主页</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/friend_ship/">友链</a></li>
        
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->

<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">


<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">


    <!-- jquery -->

<script src="/lib/jquery/jquery.min.js"></script>


<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>

<!-- clipboard -->

  
<script src="/lib/clipboard/clipboard.min.js"></script>

  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"复制到粘贴板!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "复制成功!");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

    <script type="text/javascript">
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?54382acbd8c4bc66535bce135e0ac166";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>

<!-- Disqus Comments -->


</body>
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https'){
   bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
  }
  else{
  bp.src = 'http://push.zhanzhang.baidu.com/push.js';
  }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
</html>
